//
//  Arrays.swift
//  ShakeViewKit_Example
//
//  Created by godox on 2021/11/9.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import Foundation


extension Array {
    /// 给数组扩展一个安全下标，用于检测小标是否越界，越界直接返回nil
    subscript (safe index: Int) -> Element? {
        guard index >= 0 && index < self.count else {
            return nil
        }
        return self[index]
    }
}


extension String {
    
    var nilOrEmpty: String? {
        self.isEmpty ? nil : self
    }
    
}
